import { computed, toRef } from 'vue';
import { useStore } from 'vuex';
import { actions } from '@/consts/maintaincheckorder.consts';
import { examRpairOrderAction } from '@/setup/maintaincheckorder/FunctionForUserExam';
export default function useMaintenanceOrderConfigSetup (props) {
    const propKey = props.orderItem ? 'orderItem' : 'maintiancheckdata';
    const orderItem = toRef(props, propKey);
    // const orderItem = toRef(props, 'orderItem');
    const store = useStore();
    const userinfo = store.state.userinfo;
    const {

        // 工单转派
        transfer,
        // 结单
        endorder,
        // 处理-移动端 进入记录也进行处理
        deal,
        // 记录-移动端 记录记录页查看
        record,
        /// 取消-移动端 设备点检页取消
        cancel,
        /// 提交-移动端 设备点检页提交
        submit,
        // 验收
        check
    } = actions;
    // 进度百分比值
    const procRate = computed(() => {
        return (orderItem.value.status / 4) * 100;
    });
    // 进度百分比文本
    const procRateTxt = computed(() => {
        return orderItem.value.status + '/4';
    });

    const isShowtransfer = computed(() => {
        return examRpairOrderAction(transfer, orderItem.value, userinfo);
    });
    const isShowendorder = computed(() => {
        return examRpairOrderAction(endorder, orderItem.value, userinfo);
    });
    const isShowdeal = computed(() => {
        return examRpairOrderAction(deal, orderItem.value, userinfo);
    });
    const isShowrecord = computed(() => {
        return examRpairOrderAction(record, orderItem.value, userinfo);
    });
    const isShowcancel = computed(() => {
        return examRpairOrderAction(cancel, orderItem.value, userinfo);
    });
    const isShowsubmit = computed(() => {
        return examRpairOrderAction(submit, orderItem.value, userinfo);
    });
    const isShowcheck = computed(() => {
        return examRpairOrderAction(check, orderItem.value, userinfo);
    });

    return {
        procRate,
        procRateTxt,
        isShowtransfer,
        isShowendorder,
        isShowdeal,
        isShowrecord,
        isShowcancel,
        isShowsubmit,
        isShowcheck
    };
}
